package com.sdu.cloudservice.entity;

import javax.persistence.*;
import java.util.Objects;

/**
 * Create by zekdot on 19-6-22.
 */
@Entity
@Table(name = "actual_price", schema = "cloud_service", catalog = "")
@IdClass(ActualPriceEntityPK.class)
public class ActualPriceEntity {
    private String zoneId;
    private String instanceId;
    private String time;
    private double origin;
    private double spot;

    @Id
    @Column(name = "zone_id")
    public String getZoneId() {
        return zoneId;
    }

    public void setZoneId(String zoneId) {
        this.zoneId = zoneId;
    }

    @Id
    @Column(name = "instance_id")
    public String getInstanceId() {
        return instanceId;
    }

    public void setInstanceId(String instanceId) {
        this.instanceId = instanceId;
    }

    @Id
    @Column(name = "time")
    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    @Basic
    @Column(name = "origin")
    public double getOrigin() {
        return origin;
    }

    public void setOrigin(double origin) {
        this.origin = origin;
    }

    @Basic
    @Column(name = "spot")
    public double getSpot() {
        return spot;
    }

    public void setSpot(double spot) {
        this.spot = spot;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ActualPriceEntity that = (ActualPriceEntity) o;
        return Double.compare(that.origin, origin) == 0 &&
                Double.compare(that.spot, spot) == 0 &&
                Objects.equals(zoneId, that.zoneId) &&
                Objects.equals(instanceId, that.instanceId) &&
                Objects.equals(time, that.time);
    }

    @Override
    public int hashCode() {
        return Objects.hash(zoneId, instanceId, time, origin, spot);
    }
}
